nums = [1,2,3,4,5,6,7,8]
words = ["apple","banana","cherry"]
mixed = [1,"hello",3.1415]
empty = []
print(f"words中元素有: {len(words)}")
##访问 list 中的元素
#print(nums[0])
#print(nums[-1])

##修改元素
#nums[2]=999888
#print(nums[2])

##添加元素
nums.append(990011)
nums.insert(0,1111222)
#for num in nums:
#   print(num)
for num in nums:
    print(num,end=",")

print("==========================")
##删除元素
nums.remove(6)
print(nums.pop())
print(nums.pop(0))
for num in nums:
    print(num,end=",")
print("==========================")
## 列表长度
print("words中元素有："+str(len(words)))

##排序和反转
print("=======排序和反转========")
words.sort()
print(words)
print(nums)
nums.sort()
print(nums)
nums.sort(reverse = True)
print(nums)

##列表切片（取出一部分）
print("=========列表切片（取出一部分）==========")
print(nums[1:5])
print(nums[:1])
print(nums[-3:])

##判断是否存在
if 8 in nums:
    print("元素 8 存在！")

##列表的拼接与重复
a=[2024,2025]
b=[2022,2023]
c=b+a
print(c)
d=b*2+c*2
print(d)
